/*
 * @fileOverview: 案件管理
 * @Author: xiaoyangzhao
 * @Date:   2018-07-31 11:19:37
 * @Last Modified by:   xiaoyangzhao
 * @Last Modified time: 2019-08-06 16:29:29
 */

import request from '@/utils/request'
import { route_origins, route_path_get } from '@/api/routes'

console.log('route_origins:', route_origins)
const currentRoute = route_origins + 'report/'
// request.withCredentials = false

/**
 * [reportCoverHome 首页 覆盖率报表数据]
 * @return {Function}     [异步接口方法]
 */
export function reportCoverHome(params) {
  return request({
    url: currentRoute + 'cover/query/home',
    method: 'get',
    params
  })
}

/**
 * [statReportManageGet 报表生成设置get]
 * @param  {Object} params          [案件类型查询条件]
 * @return {Function}               [request]
 */
export function statReportManageGet(params) {
  return request({
    url: currentRoute + 'conf/query',
    method: 'get',
    params
  })
}

/**
 * [statReportManagePost 报表生成设置post]
 * @param  {Object} params          [列表查询条件]
 * @return {Function}               [request]
 */
export function statReportManagePost(params) {
  params = request.filterPostData(params)
  return request({
    url: currentRoute + route_path_get + 'conf/save',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    transformRequest: request._origin.transformRequest,
    method: 'post',
    data: params
  })
}

/**
 * [reportViewList 查看所有报表]
 * @return {Function}               [request]
 */
export function reportViewList(params) {
  params = request.filterPostData(params)
  return request({
    // url: currentRoute + 'report_view/list',
    url: route_origins + 'report/' + 'report_view/list',
    method: 'get',
    params
  })
}

/**
 * [reportViewStatCase 案件覆盖率统计表 -首页]
 * @return {Function}               [request]
 */
export function reportViewStatCaseIndex(params) {
  return request({
    url: currentRoute + 'cover/query/home',
    method: 'get',
    params
  })
}

/**
 * [reportViewStatCase 案件覆盖率统计表]
 * @return {Function}               [request]
 */
export function reportViewStatCase(params) {
  return request({
    url: currentRoute + 'cover/query',
    method: 'get',
    params
  })
}

/**
 * [reportCoverExport 案件覆盖率统计表]
 * @return {Function}               [request]
 */
export function reportCoverExport(params) {
  return request({
    url: currentRoute + 'cover/export',
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
      // 'Content-Type': 'application/x-www-form-urlencoded'
    },
    transformRequest: request._origin.transformRequest,
    data: params
  })
}

/**
 * [reportBillExport 案件回款情况统计表]
 * @return {Function}               [request]
 */
export function reportBillExport(params) {
  return request({
    url: currentRoute + 'bill/export',
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    transformRequest: request._origin.transformRequest,
    data: params
  })
}

/**
 * [avgEfficiencyQuery 平均处理时效统计表]
 * @param {Number}      [reportId]
 * @return {Function}   [request]
 */
export function avgEfficiencyQuery(params) {
  return request({
    url: currentRoute + 'avg_efficiency/query',
    method: 'get',
    params
  })
}

/**
 * [reportViewPtpWeekHour 小组周案件处理时效统计表]
 * @return {Function}               [request]
 */
export function reportViewPtpWeekHour(params) {
  return request({
    // url: currentRoute + 'report_view/ptp/week_hour',
    url: currentRoute + 'efficiency_week/query',
    method: 'get',
    params
  })
}

/**
 * [reportViewPtpLastWeekHour 小组周案件处理时效环比统计表]
 * @return {Function}               [request]
 */
export function reportViewPtpLastWeekHour(params) {
  return request({
    // url: currentRoute + 'report_view/ptp/last_week_hour',
    url: currentRoute + 'efficiency_week_on_week/query',
    method: 'get',
    params
  })
}

/**
 * [reportHourExport 案件平均处理时效统计表导出]
 * @return {Function}               [request]
 */
export function reportHourExport(params) {
  return request({
    url: currentRoute + 'avg_efficiency/export',
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    transformRequest: request._origin.transformRequest,
    data: params
  })
}

/**
 * [reportWeekExport 周案件处理时效统计表导出]
 * @return {Function}               [request]
 */
export function reportWeekExport(params) {
  return request({
    url: currentRoute + 'efficiency_week/export',
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    transformRequest: request._origin.transformRequest,
    data: params
  })
}

/**
 * [reportLastWeekExport 周案件处理时效环比统计表导出]
 * @return {Function}               [request]
 */
export function reportLastWeekExport(params) {
  return request({
    url: currentRoute + 'efficiency_week_on_week/export',
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    transformRequest: request._origin.transformRequest,
    data: params
  })
}

/**
 * [caseMultiAssignOwner 案件管理-弹层-分配: 给案件重新分派一个owner]
 * @param  {Array}  caseIds         [案件id]
 * @param  {String} ownerId         [新owner id]
 * @return {Function}               [request]
 */
export function caseMultiAssignOwner(params) {
  return request({
    url: currentRoute + 'case/multiAssignOwner',
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    transformRequest: request._origin.transformRequest,
    data: params
  })
}

/**
 * [queryPayBackContactList 案件管理-弹层-贷后催收-案件联系人信息查询]
 * @param  {Number} sid             [沟通记录ID，跟基本信息关联起来]
 * @return {Function}               [request]
 */
export function queryAddCommFile(params) {
  return request({
    url: currentRoute + 'case/addCommFile',
    method: 'post',
    params
  })
}

/**
 * [queryPayBackAddressList 案件管理-弹层-贷后催收-案件地址信息查询]
 * @return {Function}               [request]
 */
export function queryPayBackAddressList(params) {
  params = request.filterPostData(params)
  return request({
    url: currentRoute + 'case/listAddress',
    method: 'get',
    params
  })
}

/**
 * [queryPayBackContactAdd 案件管理-弹层-贷后催收-案件联系人信息新增]
 * @return {Function}               [request]
 */
export function queryPayBackContactAdd(params) {
  params = request.filterPostData(params)
  return request({
    url: currentRoute + route_path_get + 'case/addContact',
    method: 'get',
    params
  })
}
